
#include "main.h" 


volatile near bit Time_10ms;
volatile near bit Time_100ms;
volatile near bit Time_500ms;
volatile near bit Time_1000ms;
volatile near bit Time_1Min;

unsigned int Global_Timer_10ms = 0;
unsigned int Global_Timer_1000ms = 0;


void SysTime( void )
{
	static unsigned char Divider_500ms = 50, Divider_1Min = 60, Divider_1Sec = 2, Divider_100ms = 10;
	
	Time_1000ms = FALSE;
	Time_10ms = FALSE;
	Time_100ms = FALSE;
	Time_500ms = FALSE;
	Time_1Min = FALSE;

	if ( TMR0IF )
	{
		TMR0IF = 0;
		TMR0 = -PERIOD_10mS; 
		Time_10ms = TRUE;
		Global_Timer_10ms++;
		
		if ( --Divider_100ms == 0 )
		{
			Divider_100ms = 10;
			Time_100ms = TRUE;
		}

		if ( --Divider_500ms == 0 )
		{
			Divider_500ms = 50;
			Time_500ms = TRUE;
			if ( --Divider_1Sec == 0 )
			{
				Divider_1Sec = 2;
				Time_1000ms = TRUE;
				Global_Timer_1000ms++; 
			
				if ( --Divider_1Min == 0 )
				{
					Divider_1Min = 60;
					Time_1Min = TRUE;

				}
			}
		}
	}
} 
